/**
 * 消息提示封装
 */

import { ElMessageBox } from 'element-plus'

interface confirmOptions {
  title?: string
  content?: string
  confirmButtonText?: string
  cancelButtonText?: string
  type?: '' | 'success' | 'warning' | 'info' | 'error'
  sure?: () => void
  cancel?: () => void
}

/* 确认提示框 */
function confirm({
  title = '提示',
  content = '',
  confirmButtonText = '确定',
  cancelButtonText = '取消',
  type = 'warning',
  sure,
  cancel
}: confirmOptions) {
  ElMessageBox.confirm(content, title, {
    confirmButtonText: confirmButtonText,
    cancelButtonText: cancelButtonText,
    type: type
  })
    .then(() => {
      sure && sure()
    })
    .catch(() => {
      cancel && cancel()
    })
}

export { confirm }
